# -*- coding: utf-8 -*-

import  shutil
from accessFile import access
from log import  globalLog
from mkdir import OpDir

class copy():
    def __init__(self):
        pass

    def copy(self,src,dst):
        access_ = access(src)

        if access_.isFile():
            self.copyFile(src,dst)
        elif access_.isDir():
            self.copyDir(src,dst)
        else:
            globalLog.Error(src,"is not exists")

        pass

    def copyFile(self,src,dst):
        shutil.copy(src,dst)
        pass

    def copyDir(self,src,dst):
        access_ = access(dst)
        if not access_.isDir():
            OpDir.mkdir(dst)
        shutil.copytree(src,dst)
        pass


CopyCmd = copy()